<?php
include(dirname(__FILE__).'/../includes.php5');

include($project_path.'/class/fw/listGroupData.php5');
session_start();

$lg = new fwListGroupData('test');
$lg->fields = array(
	array(
		'name' => 'action',
		'label' => 'action', 
		'content' => '!', 
		'index' => 0, 
		'width' => 20, 
		'resizable' => false, 
		'data_field' => 'installed_html', 
		'group_type' => 'installed',
	),
	array(
		'name' => 'name',
		'label' => 'nom', 
		'content' => '', 
		'index' => 1, 
		'width' => 200, 
		'resizable' => true, 
		'data_field' => 'name', 
		'group_type' => 'string',
	),
	array(
		'name' => 'description1',
		'label' => 'description', 
		'content' => '', 
		'index' => 2, 
		'width' => '*', 
		'resizable' => true,
		'data_field' => 'description',
		'group_type' => 'string',
		),
	);

$lg->groupsTypes = array(
	'installed' => array(
		'data_field' => 'installed', 
		'data_type' => 'int', 
		'data_label' => array(
			0 => 'n\'est pas installé',
			1 => 'installé',
		),
	)
);
$lg->onSelectChange = "toto";

$lg->datas = array();
for($i=1; $i<50; $i++)
{
	$lg->datas[] = array(
		'installed_html' => rand(0, 1), 
		'name' => 'element '.$i, 
		'description' => 'description de l\'element '.$i
	);
}

$lg->groups = array();
$lg->order = '';
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "XHTML1-s.dtd" >
<html>
	<head>
		<link rel="stylesheet" href="./css/commun/listgroup.css">
		<script src="./js/commun/listgroup.js"></script>
		<script src="./js/commun/tools.js"></script>
		<script src="./js/commun/ajax.js"></script>
	</head>
	<body>
		<div style="position:absolute;width:600px;height:400px">
			<textarea><?php echo htmlspecialchars($lg->formatJavascript());?></textarea>
		</div>
<script>
function toto(ele)
{
alert(ele.name)
}
var textareas = document.getElementsByTagName("textarea")
for(var i=0; i<textareas.length; i++)
{
	var lg = new listGroup(textareas[i]);
}


if (window.HTMLElement)
{
    var element = HTMLElement.prototype;
    var capture = ["click", "mousedown", "mouseup", "mousemove", "mouseover", "mouseout" ];
    element.setCapture = function()
    {
        var self = this;
        var flag = false;
        this._capture = function(e)
        {
            if (flag) {return}
            flag = true;
            var event = document.createEvent("MouseEvents");
            event.initMouseEvent(e.type,
                e.bubbles, e.cancelable, e.view, e.detail,
                e.screenX, e.screenY, e.clientX, e.clientY,
                e.ctrlKey, e.altKey, e.shiftKey, e.metaKey,
                e.button, e.relatedTarget);
            self.dispatchEvent(event);
            flag = false;
        };
        for (var i=0; i<capture.length; i++)
        {
            window.addEventListener(capture[i], this._capture, true);
        }
    };

    element.releaseCapture = function()
    {
        for (var i=0; i<capture.length; i++)
        {
            window.removeEventListener(capture[i], this._capture, true);
        }
        this._capture = null;
    };

}
</script>
	</body>
</html>